﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity;
using Winz.JsonModel;

namespace Winz.FoeBot.DataLayer
{
        public class FoeContext : DbContext
        {


            public FoeContext()
                : base("foeDbConnectionString")
            {
                AppDomain.CurrentDomain.SetData("DataDirectory",
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData));

                Database.SetInitializer<FoeContext>(new FoeDbInitializer());
                //Database.SetInitializer<FoeContext>(new DropCreateDatabaseAlways<FoeContext>());
                //Database.SetInitializer<ProductContext>(new CreateDatabaseIfNotExists<ProductContext>());
                //Database.SetInitializer<SchoolDBContext>(new DropCreateDatabaseIfModelChanges<SchoolDBContext>());
                //Database.SetInitializer<SchoolDBContext>(new DropCreateDatabaseAlways<SchoolDBContext>());
                //Database.SetInitializer<SchoolDBContext>(new SchoolDBInitializer());
            }

//            public DbSet<Era> Eras { get; set; }
            public DbSet<Good> Goods { get; set; }
            public DbSet<Resources> Resources { get; set; }
            public DbSet<UserData> Users { get; set; }
            public DbSet<Research> Researchs { get; set; }
            public DbSet<Progress> ResearchProgress { get; set; }
            public DbSet<GoodTranslation> GoodTranslations { get; set; }
            public DbSet<TradeOffer> TradeOffers { get; set; }

            

            



            protected override void OnModelCreating(DbModelBuilder modelBuilder)
            {
                // Set composite keys
                modelBuilder.Entity<Good>().HasKey(k => new { k.RessoureId,k.GoodId});
                modelBuilder.Entity<Progress>().HasKey(k => new { k.PlayerId, k.ResearchId });
            }

        }
    
}
